<%@page import="java.security.SecureRandom"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%

SecureRandom random=SecureRandom.getInstance("SHA1PRNG");
long seq=random.nextLong();
String randomNum =""+seq;
session.setAttribute("random_session",randomNum);

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link href="<%=basePath%>static/h-ui/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="<%=basePath%>static/h-ui.admin/css/H-ui.login.css" rel="stylesheet" type="text/css" />
<link href="<%=basePath%>static/Hui-iconfont/1.0.8/iconfont.css" rel="stylesheet" type="text/css" />
<link href="<%=basePath%>static/h-ui.admin/css/style.css" rel="stylesheet" type="text/css" />
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="<%=basePath%>static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript">

<%-- $(document).ready(function () {

	$(document).keyup(function (evnet) {
	if (evnet.keyCode == '13') {
		var url = "<%=basePath%>user/login.action";
		var data = $("#login").serialize(); //表单数据
		$.post(url, data, function(msg) {
			if (msg == "success") {//msg =success表示修改成功
				alert("登录成功");
				window.location.href='<%=basePath%>user/loginJump.action';
			}else if (msg == "miss") {
				alert("登录出错");
			}else {
				alert("账户或者密码出错");
			}
		});
	}
	});

	}); --%>
$(function() {
	$('#btn-login').click(function() {
		//表单目标
		
		if(!$("#userName")||$("#userName").val()==""){
			alert("用户名不能为空！");
			return;
		}
		if(!$("#passWord")||$("#passWord").val()==""){
			alert("密码不能为空！");
			return;
		}
		if(!$("#valCode")||$("#valCode").val()==""){
			alert("验证码不能为空！");
			return;
		}
		
		var url = "<%=basePath%>user/val.action";
		var data = $("#login").serialize(); //表单数据
		$.post(url, data, function(msg) {
			if (msg == "sucess") {//msg =success表示修改成功
				alert("登陆成功");
				$("#login").submit();
			}else {
				alert(msg);
				return;
			}
		});
		
	});
	
	$("#imgObj").click(function(){
		//var codeUrl = $(this).attr("data-url");
		//alert(codeUrl);
		$(this).attr("src","${pageContext.request.contextPath}/user/code.action?x="+Math.random());
	});
	
})
</script>
<title>生活微笑管理系统</title>
</head>
<body>
	<input type="hidden" id="TenantId" name="TenantId" value="" />
	<div class="header"></div>
	<div class="loginWraper">
		<div id="loginform" class="loginBox">
			<label style="color: red"><c:if test="msg!=null">${msg}</c:if></label>
			<form class="form form-horizontal" method="post" id = "login" action="<%=basePath%>user/login.action">
				<input type="hidden" name="random_form" value=<%=randomNum%>></input>
				<div class="row cl">
					<label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60d;</i></label>
					<div class="formControls col-xs-8">
						<input id="userName" name="userName" type="text" placeholder="账户"
							class="input-text size-L" autocomplete="off" />
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-3"><i class="Hui-iconfont">&#xe60e;</i></label>
					<div class="formControls col-xs-8">
						<input id="passWord" name="password" type="password"
							placeholder="密码" class="input-text size-L" autocomplete="off" />
					</div>
				</div>
				<div class="row cl">
					<div class="formControls col-md-offset-3 col-xs-8">
						<input id="valCode" name="valCode" type="text"
							placeholder="请输入验证码" class=" input-text col-xs-4 size-L" autocomplete="off" />
						<img class="col-md-offset-1"
						src="${pageContext.request.contextPath }/user/code.action"
						data-url="${pageContext.request.contextPath }/user/code.action"
						id="imgObj" title="看不清，点击刷新" />
					</div>
				</div>
				<div class="row cl">
					<div class="formControls col-xs-8 col-xs-offset-3">
						<input name="" type="button" class="btn btn-success radius size-L"
							value="&nbsp;登&nbsp;&nbsp;&nbsp;&nbsp;录&nbsp;" id="btn-login"> 
						<input name="" type="reset" class="btn btn-default radius size-L"
							value="&nbsp;取&nbsp;&nbsp;&nbsp;&nbsp;消&nbsp;">
					</div>
				</div>
			</form>
		</div>
</body>
</html>